.TH std::experimental::optional::emplace 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::optional::emplace \- std::experimental::optional::emplace

.SH Synopsis
   template< class... Args >                                  (library fundamentals TS)
   void emplace( Args&&... args );
   template< class U, class... Args >
   void emplace( std::initializer_list<U> ilist, Args&&...    (library fundamentals TS)
   args );

   Constructs the contained value in-place. If *this already contains a value before
   the call, the contained value is destroyed by calling its destructor.

   1) Initializes the contained value by direct-initializing (but not
   direct-list-initializing) with std::forward<Args>(args)... as parameters.
   2) Initializes the contained value by calling its constructor with ilist,
   std::forward<Args>(args)... as parameters. This overload participates in overload
   resolution only if std::is_constructible<T, std::initializer_list<U>&,
   Args&&...>::value is true.

.SH Parameters

   args...   -   the arguments to pass to the constructor
   ilist     -   the initializer list to pass to the constructor
.SH Type requirements
   -
   T must be constructible from Args...
   -
   T must be constructible from std::initializer_list and Args...

.SH Return value

   \fI(none)\fP

.SH Exceptions

   Any exception thrown by the selected constructor of T. If an exception is thrown,
   *this does not contain a value after this call (the previously contained value, if
   any, had been destroyed).

.SH See also

   operator= assigns contents
             \fI(public member function)\fP

.SH Category:
     * Noindexed pages
